package com.drojian;

import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.drojian.adapter.GoodsAdapter;
import com.drojian.entity.Goods;
import com.drojian.presenter.GoodsPresenter;
import com.drojian.view.IGoodsView;
import java.util.List;

public class MainActivity extends AppCompatActivity implements IGoodsView {
    private  GoodsPresenter presenter;
    private RecyclerView recyclerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        initView();
        presenter = new GoodsPresenter(this);
        presenter.fetch();
    }

    @Override
    public void showGoodsView(List<Goods> goods) {
        recyclerView.setAdapter(new GoodsAdapter(goods));


    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {
        super.onPointerCaptureChanged(hasCapture);
    }

    public void  initView(){
        recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}